#include "stdafx.h"
#include "DayRecord.h"


CDayRecord::CDayRecord()
{
	mOwner = 0;
	mSize  = 0;
	mStatus = RDS_VIRGIN;
}


CDayRecord::CDayRecord(CRecord* pRecord)
{
	mOwner = pRecord->mOwner;
	mStatus = pRecord->mStatus;
	mSize    = 0;
	mType   = mType;
	mVirginNumber  = 0;

	mBeginTime  = CTime(pRecord->mBeginTime.GetYear(), 
						pRecord->mBeginTime.GetMonth(),
					    pRecord->mBeginTime.GetDay(),
						0, 0, 0);
	mEndTime  = mBeginTime  + CTimeSpan(1, 0, 0, 0);

	Add(pRecord);
}


CDayRecord::~CDayRecord()
{
}


CRecord* CDayRecord::GetFirstClearable()
{
	if (!mRecordList.empty()) {
		std::list<CRecord*>::reverse_iterator iter  = mRecordList.rbegin();
		for (; iter != mRecordList.rend(); iter++) {
			if ((*iter)->mStatus == RDS_NORMAL || (*iter)->mStatus == RDS_VIRGIN) {
				return (*iter);
			}
		}
	}
	return NULL;
}
